Skip to content

Conversation

ahejlsberg
Copy link
Member

With #3516 it is now possible for a class to extend null as permitted by ES6. This PR changes the __extends helper emitted for derived classes to properly support null base arguments in ES5 environments:

var __extends = (this && this.__extends) || function (d, b) {
    for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
    function __() { this.constructor = d; }
    d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};

Since Object.create is available only in ES5, an exception will be thrown for a null base argument in an ES3 environment. But that was already the case before, so we're no worse off.

@ahejlsberg ahejlsberg changed the title Extends null Support null in __extends helper Jun 16, 2015
@rbuckton
Copy link
Contributor

👍

3 similar comments
@DanielRosenwasser
Copy link
Member

👍

@mhegazy
Copy link
Contributor

mhegazy commented Jun 17, 2015

👍

@vladima
Copy link
Contributor

vladima commented Jun 17, 2015

👍

@RyanCavanaugh
Copy link
Member

We should consider addressing #1601 as part of this, if possible

@ahejlsberg
Copy link
Member Author

Let's have resolution of #1601 be a separate issue.

ahejlsberg added a commit that referenced this pull request Jun 17, 2015
Support null in __extends helper
@ahejlsberg ahejlsberg merged commit 33b0a56 into master Jun 17, 2015
@ahejlsberg ahejlsberg deleted the extendsNull branch June 17, 2015 20:15
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants